﻿using System.Linq;
using RAP.Framework.Libary.DomTemplateBuilder.Handler.Conditional;
using RAP.Framework.Libary.Utils;
using RAP.Framework.Libary.DomTemplateBuilder.Element.Collection.IterateItem;
using RAP.Framework.Libary.DomTemplateBuilder.Interface;

namespace RAP.Framework.Libary.DomTemplateBuilder.Handler.IterateItem
{
	public class IsFirstItemHandler : ConditionalHandler
    {
        public new IsFirstItem Element
        {
            get
            {
                return base.Element as IsFirstItem;
            }
        }

        public override bool IsCondition ( object rootParamObject, object parentParamObject, ITemplateRenderContext context )
        {
			var iterateCotext = context.ToDictionary ( IterateHandler.ITERATE_CONEXT_KEY );
            return iterateCotext.ToBoolean ( IterateHandler.ITERATE_IS_FIRST );
        }
    }
}
